package com.mlk.waste.api;

import com.mlk.constant.OK;
import com.mlk.core.component.page.Pager;
import com.mlk.core.util.ServerResponse;
import com.mlk.waste.service.EngWasteUserOrderService;
import com.mlk.waste.vo.EngWasteOrderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 *  废品回收的流程:
 *  1. 客户创建订单
 *  2. 分配订单
 *         抢单 + 派单 ---> 实际就是找一个处理人
 *  3. 业务员定价
 *  4. 管理员审核
 *  5. 审核通过, 业务员完成订单.
 *  6. 客户确认订单 + 给用户增加余额 + 增加积分项 等操作
 *  7 . 订单彻底完成
 *
 *   增加一个开关,是否需要后台审核的开关...
 *   现在需要 : 将小函数进行封装, 后面的流程会不断的进行修改.
 */

@Api("废品回收客户订单api")
@RestController
@RequestMapping("/api/wasteUserOrder")
public class EngWasteUserOrderAPI {

    @Resource
    private EngWasteUserOrderService engWasteUserOrderService;


    @ApiOperation("订单录入")
    @ResponseBody
    @PostMapping("addOrder")
    @OK
    public ServerResponse addOrder(@RequestBody EngWasteOrderVO vo){
        return this.engWasteUserOrderService.addOrder(vo);
    }

    /**
     * 查询所有的各种状态的订单(对于客户端来说)
     * @return
     */
    @GetMapping("queryEveryStatusOrder")
    @ResponseBody
    @OK
    public ServerResponse queryEveryStatusOrder(String openId,Integer type){
        return this.engWasteUserOrderService.queryEveryStatusOrder(openId,type);
    }

    /**
     * 取消订单
     * @param orderCode
     * @return
     */
    @ResponseBody
    @GetMapping("cancelOrder")
    @OK
    public ServerResponse cancelOrder(String orderCode){
        return this.engWasteUserOrderService.cancelOrder(orderCode);
    }

    /**
     * 查询订单详情
     * @param orderCode
     * @return
     */
    @GetMapping("selectOrderDetail")
    @ResponseBody
    @OK
    public ServerResponse selectOrderDetail(String orderCode){
        return this.engWasteUserOrderService.selectOrderDetail(orderCode);
    }

    /**
     * 业务员抢单列表
     * @return
     */
    @GetMapping("queryAllWaitOrder")
    @ResponseBody
    @OK
    public ServerResponse queryAllWaitOrder(String openId){
        return this.engWasteUserOrderService.queryAllWaitOrder(openId);
    }

    /**
     * 订单明细,该接口的内容包含订单的主体信息和订单的明细信息
     * @return
     */
    @GetMapping("orderDetails")
    @ResponseBody
    @OK
    public ServerResponse orderDetails(String orderCode){
        return this.engWasteUserOrderService.orderDetails(orderCode);
    }

    /**
     * 业务员抢单操作
     * @param orderCode
     * @param openId
     * @return
     */
    @PostMapping("manageOrder")
    @ResponseBody
    @ApiOperation("抢单")
    @OK
    public ServerResponse manageOrder(String orderCode,String openId){
        return this.engWasteUserOrderService.manageOrder(orderCode,openId);
    }


    @GetMapping("waitPick")
    @ResponseBody
    @ApiOperation("待收货")
    @OK
    public ServerResponse waitPick(String openId){
        return this.engWasteUserOrderService.waitPick(openId);
    }

    /**
     * 业务员定价(实际就是重新添加订单)
     * @return
     */
    @PostMapping("confirmOrder")
    @ResponseBody
    @OK
    public ServerResponse confirmOrder(@RequestBody EngWasteOrderVO vo){
        return this.engWasteUserOrderService.confirmOrder(vo);
    }

    /**
     * 获取审核意见
     * @param orderCode
     * @return
     */
    @GetMapping("getVerifyAdvice")
    @OK
    public ServerResponse getVerifyAdvice(String orderCode){
        return this.engWasteUserOrderService.getVerifyAdvice(orderCode);
    }

    /**
     * 获取所有完成的订单
     * @param openId
     * @return
     */
    @GetMapping("getAllFinishedOrder")
    public Pager getAllFinishedOrder(String openId){
        return this.engWasteUserOrderService.getAllFinishedOrder(openId);
    }

    /**
     * 业务员确认
     * @return
     */
    @PostMapping("empConfirm")
    public ServerResponse empConfirm(String orderCode){
        return this.engWasteUserOrderService.empConfirm(orderCode);
    }


    /**
     * 根据用户输入的姓名,关联查询出相似信息的记录内容
     * @return
     */
    @GetMapping("AIInput")
    public ServerResponse AIInput(String openId,String name,String phone){
        return this.engWasteUserOrderService.AIInput(openId,name,phone);
    }

}
